package cn.cdeden.common.oss.enumd;

import lombok.AllArgsConstructor;
import lombok.Getter;
import software.amazon.awssdk.services.s3.model.BucketVersioningStatus;

/**
 * @ProjectName : ecm_hou
 * @Package : com.cdyd.ecm.storage.minio.enums
 * @ClassName : VersioningStatus
 * @Author : Yu.
 * @Description : // 版本控制
 * @Date : 2022/12/9 17:33
 * @Version : 1.0
 */
@Getter
@AllArgsConstructor
public enum VersioningStatus {

    OFF("0",null),
    ENABLED("1","Enabled"),
    SUSPENDED("2","Suspended");

    private final String type;
    private final String value;



    public static VersioningStatus fromString(String statusString) {
        if ("Enabled".equals(statusString)) {
            return ENABLED;
        } else {
            return "Suspended".equals(statusString) ? SUSPENDED : OFF;
        }
    }

    public static BucketVersioningStatus from(VersioningStatus statusString) {
        if ("Enabled".equals(statusString.getValue())) {
            return BucketVersioningStatus.ENABLED;
        } else {
            return "Suspended".equals(statusString.getValue()) ? BucketVersioningStatus.SUSPENDED : BucketVersioningStatus.UNKNOWN_TO_SDK_VERSION;
        }
    }


}
